import axios from "../../http/axios.js";
import {
  apiGetServingPatients
} from "../../http/server.js";

export function getUserpatientsList() {
  return new Promise((resolve, reject) => {
    var userInfo = wx.getStorageSync("userInfo");
    var data = {
      userId: userInfo.userId,
      page: 1,
      pageSize: 1000
    }
    axios({
      url: apiGetServingPatients,
      data: data
    }).then(res => {
      var list = [];
      res.records.forEach((item, index) => {
        var item = {
          ...item,
          name: item.userName,
          relationship: item.relation,
          sex: item.sex == 1 ? "男" : "女"
        }
        list.push(item)
      })
      resolve(list);
    }).catch(fail => {
      reject(fail);
    })
  })
}